﻿using MediatR;
using S_Userinfor.Domains;
using S_UserInfor.Infrasturctre.Interface;
using S_UserInfor.Read.Api.Application.Commands;

namespace S_UserInfor.Read.Api.Application.CommandsHanders
{
    public class UserBaCommandsHanders : IRequestHandler<UserBaCommands, User>
    {
        private readonly IDapperUserRepository _dapper;

        public UserBaCommandsHanders(IDapperUserRepository dapper)
        {
            _dapper = dapper;
        }
        public async Task<User> Handle(UserBaCommands request, CancellationToken cancellationToken)
        {
            string sql = "SELECT * FROM User WHERE Id = @Id";
            return await _dapper.GetOne(request.Id, sql);
        }
    }
}